
!$OPENAD XXX File_start [OAD_intrinsics.f90]
MODULE oad_intrinsics
use OAD_active
use w2f__types
IMPLICIT NONE
SAVE
!
!     **** Statements ****
!
END MODULE

C$OPENAD XXX File_start [all_globals_mod.f]
      MODULE all_globals_mod
      use OAD_active
      use w2f__types
      IMPLICIT NONE
      SAVE
C
C     **** Statements ****
C
      END MODULE

C$OPENAD XXX File_start [head.f]
      MODULE m1
      use OAD_active
      use w2f__types
      use oad_intrinsics
      IMPLICIT NONE
      SAVE
C
C     **** Statements ****
C
      CONTAINS
C#########################################################
C This file is part of OpenAD released under the LGPL.   #
C The full COPYRIGHT notice can be found in the top      #
C level directory of the OpenAD distribution             #
C#########################################################

        SUBROUTINE FOO(X, N)
          use OAD_tape
          use OAD_rev

C original arguments get inserted before version
C         ! and declared here together with all local variables
C         ! generated by xaifBooster

        use w2f__types
        IMPLICIT NONE
C
C       **** Parameters and Result ****
C
        INTEGER(w2f__i4) N
        REAL(w2f__8) X(1 : N)


          integer iaddr
          external iaddr
C
C       **** Statements ****
C

         if (our_rev_mode%plain) then
C original function
          end if
          if (our_rev_mode%tape) then
C taping
          end if
          if (our_rev_mode%adjoint) then
C adjoint
          end if
        end subroutine FOO
      END

      MODULE m2
      use OAD_active
      use w2f__types
      use oad_intrinsics
      use m1
      IMPLICIT NONE
      SAVE
C
C     **** Statements ****
C
      CONTAINS
C#########################################################
C This file is part of OpenAD released under the LGPL.   #
C The full COPYRIGHT notice can be found in the top      #
C level directory of the OpenAD distribution             #
C#########################################################

        SUBROUTINE BAR(X, N)
          use OAD_tape
          use OAD_rev

C original arguments get inserted before version
C         ! and declared here together with all local variables
C         ! generated by xaifBooster

        use w2f__types
        IMPLICIT NONE
C
C       **** Global Variables & Derived Type Definitions ****
C
        INTEGER(w2f__i8) OpenAD_Symbol_0
        INTEGER(w2f__i8) OpenAD_Symbol_1
        INTEGER(w2f__i8) OpenAD_Symbol_2
        INTEGER(w2f__i8) OpenAD_Symbol_3
        INTEGER(w2f__i8) OpenAD_Symbol_4
        INTEGER(w2f__i8) OpenAD_Symbol_5
C
C       **** Parameters and Result ****
C
        INTEGER(w2f__i4) N
        type(active) :: X(1:N)
C
C       **** Local Variables and Functions ****
C
        INTEGER(w2f__i4) I
        INTEGER(w2f__i4) OAD_CTMP0
        INTEGER(w2f__i4) OpenAD_Symbol_6
        type(active) :: OpenAD_prp_0
        REAL(w2f__8) OpenAD_tyc_0(:)
        ALLOCATABLE OpenAD_tyc_0
        REAL(w2f__8) OpenAD_tyc_1(:)
        ALLOCATABLE OpenAD_tyc_1


          integer iaddr
          external iaddr
C
C       **** Statements ****
C

         if (our_rev_mode%plain) then
C original function
        DO I = 1, N, 1
          X(INT(I))%v = (X(I)%v*2.0D00)
        END DO
        I = 2
        OAD_CTMP0 = (SIZE(X)-I)
C!! requested inline of 'oad_AllocateMatching' has no defn
        CALL oad_AllocateMatching(OpenAD_tyc_0,X)
C!! requested inline of 'oad_convert' has no defn
        CALL oad_convert(OpenAD_tyc_0,X)
        CALL FOO(OpenAD_tyc_0(I),OAD_CTMP0)
C!! requested inline of 'oad_ShapeTest' has no defn
        CALL oad_ShapeTest(OpenAD_tyc_0,X)
C!! requested inline of 'oad_convert' has no defn
        CALL oad_convert(X,OpenAD_tyc_0)
          end if
          if (our_rev_mode%tape) then
C taping
        OpenAD_Symbol_2 = 0_w2f__i8
        DO I = 1,N,1
          X(INT(I))%v = (X(I)%v*2.0D00)
          integer_tape(integer_tape_pointer) = I
          integer_tape_pointer = integer_tape_pointer+1
          OpenAD_Symbol_2 = (INT(OpenAD_Symbol_2)+INT(1_w2f__i8))
        END DO
        integer_tape(integer_tape_pointer) = OpenAD_Symbol_2
        integer_tape_pointer = integer_tape_pointer+1
        I = 2
        OAD_CTMP0 = (SIZE(X)-I)
C!! requested inline of 'oad_AllocateMatching' has no defn
        CALL oad_AllocateMatching(OpenAD_tyc_0,X)
C!! requested inline of 'oad_convert' has no defn
        CALL oad_convert(OpenAD_tyc_0,X)
        CALL FOO(OpenAD_tyc_0(I),OAD_CTMP0)
C!! requested inline of 'oad_ShapeTest' has no defn
        CALL oad_ShapeTest(OpenAD_tyc_0,X)
C!! requested inline of 'oad_convert' has no defn
        CALL oad_convert(X,OpenAD_tyc_0)
        integer_tape(integer_tape_pointer) = I
        integer_tape_pointer = integer_tape_pointer+1
        integer_tape(integer_tape_pointer) = OAD_CTMP0
        integer_tape_pointer = integer_tape_pointer+1
          end if
          if (our_rev_mode%adjoint) then
C adjoint
        integer_tape_pointer = integer_tape_pointer-1
        OAD_CTMP0 = integer_tape(integer_tape_pointer)
        integer_tape_pointer = integer_tape_pointer-1
        I = integer_tape(integer_tape_pointer)
C!! requested inline of 'oad_AllocateMatching' has no defn
        CALL oad_AllocateMatching(OpenAD_tyc_1,X)
        CALL FOO(OpenAD_tyc_1(I),OAD_CTMP0)
        integer_tape_pointer = integer_tape_pointer-1
        OpenAD_Symbol_0 = integer_tape(integer_tape_pointer)
        OpenAD_Symbol_1 = 1
        do while (INT(OpenAD_Symbol_1).LE.INT(OpenAD_Symbol_0))
          integer_tape_pointer = integer_tape_pointer-1
          OpenAD_Symbol_6 = integer_tape(integer_tape_pointer)
          OpenAD_prp_0%d = OpenAD_prp_0%d+X(OpenAD_Symbol_6)%d*(2.0D00)
          X(OpenAD_Symbol_6)%d = 0.0d0
          X(OpenAD_Symbol_6)%d = X(OpenAD_Symbol_6)%d+OpenAD_prp_0%d
          OpenAD_prp_0%d = 0.0d0
          OpenAD_Symbol_1 = INT(OpenAD_Symbol_1)+1
        END DO
          end if
        end subroutine BAR
      END
C#########################################################
C This file is part of OpenAD released under the LGPL.   #
C The full COPYRIGHT notice can be found in the top      #
C level directory of the OpenAD distribution             #
C#########################################################

      SUBROUTINE head(X, Y)
          use OAD_tape
          use OAD_rev

C original arguments get inserted before version
C         ! and declared here together with all local variables
C         ! generated by xaifBooster

      use OAD_active
      use w2f__types
      use oad_intrinsics
      use m2
      use oad_intrinsics
      use m2
      use oad_intrinsics
      use m2
      IMPLICIT NONE
C
C     **** Parameters and Result ****
C
      type(active) :: X(1:4)
      type(active) :: Y(1:4)
C
C     **** Local Variables and Functions ****
C
      INTEGER(w2f__i4) OAD_CTMP0


          integer iaddr
          external iaddr
C
C     **** Top Level Pragmas ****
C
C$OPENAD INDEPENDENT(X)
C$OPENAD DEPENDENT(Y)
C
C     **** Statements ****
C

         if (our_rev_mode%plain) then
C original function
      OAD_CTMP0 = 4
      CALL BAR(X,OAD_CTMP0)
      Y(1:4)%v = X(1:4)%v
          end if
          if (our_rev_mode%tape) then
C taping
      OAD_CTMP0 = 4
      CALL BAR(X,OAD_CTMP0)
      integer_tape(integer_tape_pointer) = OAD_CTMP0
      integer_tape_pointer = integer_tape_pointer+1
      Y(1:4)%v = X(1:4)%v
          end if
          if (our_rev_mode%adjoint) then
C adjoint
      X(1:4)%d = X(1:4)%d+Y(1:4)%d
      Y(1:4)%d = 0.0d0
      integer_tape_pointer = integer_tape_pointer-1
      OAD_CTMP0 = integer_tape(integer_tape_pointer)
      CALL BAR(X,OAD_CTMP0)
          end if
        end subroutine head
